<?php


/**
 * 分类树(树状结构)
 */
function getTree($arr,$pid=0,$step){

    static $tree;
    foreach($arr as $key=>$val){
        if($val['cate_pid'] == $pid){
            $flag = str_repeat('|---',$step);
            $val['cate_name'] = $flag.$val['cate_name'];
            $val['level'] = $step;
            $tree[] = $val;
            getTree($arr,$val['cate_id'],$step+1);
        }
    }
    return $tree;

}